package com.tencent.rayynxu.androidgraphicsdemos

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.View
import kotlinx.android.synthetic.main.activity_main.*

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)

        // Example of a call to a native method
        sample_text.text = stringFromJNI()

        button_gles_test.setOnClickListener { v : View ->
            Log.i("MainActivity", "button_gles_test onclick")
            val intent = Intent()
            intent.action = "android.intent.action.GLESTestActivity"
            intent.putExtra("scene", "scenes/glestest.xml")
            startActivity(intent)
        }

        collide_test.setOnClickListener { v : View ->
            Log.i("MainActivity", "collide_test onclick")
            val intent = Intent()
            intent.action = "android.intent.action.CollisionTest"
            intent.putExtra("scene", "scenes/collide.xml")
            startActivity(intent)
        }

        dynamics.setOnClickListener { v : View ->
            Log.i("MainActivity", "dynamics onclick")
            val intent = Intent()
            intent.action = "android.intent.action.Dynamics"
            intent.putExtra("scene", "scenes/dynamics.xml")
            startActivity(intent)
        }

        cs_test.setOnClickListener { v : View ->
            Log.i("MainActivity", "cs_test onclick")
            val intent = Intent()
            intent.action = "android.intent.action.CSTest"
            intent.putExtra("scene", "scenes/compute_shader.xml")
            startActivity(intent)
        }

        instanced.setOnClickListener { v : View ->
            Log.i("MainActivity", "instanced onclick")
            val intent = Intent()
            intent.action = "android.intent.action.InstancedTest"
            intent.putExtra("scene", "scenes/instanced_render.xml")
            startActivity(intent)
        }

        particle_test.setOnClickListener { v : View ->
            Log.i("MainActivity", "particle onclick")
            val intent = Intent()
            intent.action = "android.intent.action.Particles"
            intent.putExtra("scene", "scenes/particles.xml")
            startActivity(intent)
        }

        compressed_texture.setOnClickListener { v : View ->
            Log.i("MainActivity", "compressed_texture onclick")
            val intent = Intent()
            intent.action = "android.intent.action.CompressTexture"
            intent.putExtra("scene", "scenes/compressed_texture.xml")
            startActivity(intent)
        }

        mesh.setOnClickListener { v : View ->
            Log.i("MainActivity", "mesh onclick")
            val intent = Intent()
            intent.action = "android.intent.action.Mesh"
            intent.putExtra("scene", "scenes/mesh.xml")
            startActivity(intent)
        }
    }

    /**
     * A native method that is implemented by the 'native-lib' native library,
     * which is packaged with this application.
     */
    external fun stringFromJNI(): String

    companion object {
        // Used to load the 'native-lib' library on application startup.
        init {
            System.loadLibrary("render-lib")
        }
    }
}
